/*
    This file is part of SQLiteGTK, written by Aly Hirani

    SQLiteGTK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SQLiteGTK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SQLiteGTK.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MODULE_LOADER_H__
#define __MODULE_LOADER_H__

#include "include.h"
#include "guid.h"

enum _NotebookActionType
{
	NAT_NEW,
	NAT_OPEN,
	NAT_SAVE,
	NAT_CLOSE, /* Close implies using the standard NotebookHeader. Unload implies the all is unloading */
	NAT_UNLOAD
};

enum _NotebookHeaderType
{
	NHT_STANDARD,
	NHT_CUSTOM
};

enum _NotebookPluginActivateType
{
	NPCT_APP,
	NPCT_USER
};

typedef struct _NotebookPlugin NotebookPlugin;
typedef struct _NotebookPluginInfo NotebookPluginInfo;
typedef struct _NotebookPageType NotebookPageType;
typedef struct _NotebookAction NotebookAction;
typedef struct _NotebookPluginTab NotebookPluginTab;
typedef enum _NotebookActionType NotebookActionType;
typedef enum _NotebookPluginActivateType NotebookPluginActivateType;
typedef enum _NotebookPluginActivateType NotebookPluginDeactivateType;
typedef enum _NotebookHeaderType NotebookHeaderType;

typedef NotebookPluginInfo* (* plugin_get_info) ();
typedef void (* plugin_free_info)(NotebookPluginInfo *plugin_info);
typedef void (* plugin_activate)(NotebookPluginActivateType type);
typedef void (* plugin_deactivate)(NotebookPluginDeactivateType type);
typedef gboolean (* plugin_action)(const NotebookAction *action, NotebookPluginTab *tab, guint count);

/* TODO: This is a little oddly named */
struct _NotebookPluginTab
{
	GtkWidget *page;
	NotebookHeaderType header_type;
	union
	{
		gchar *title;
		GtkWidget *header;
	} header_data;
	gpointer user_data;
};

struct _NotebookAction
{
	NotebookActionType type;
	const gchar **path;
};

struct _NotebookPageType
{
	gint id;
	gchar *type;
	GdkPixbuf *image;
	GtkFileFilter **file_types;
};

struct _NotebookPluginInfo
{
	GUID *guid;
	gchar *name;
	gchar *author;
	gchar *desc;
	gchar *version;
	GdkPixbuf *image;
	NotebookPageType **types;
	
	/* GList of GUIDs */
	GList *depends;
	GList *extends;
};

struct _NotebookPlugin
{
	gint id;
	NotebookPluginInfo *info;
	gboolean activated;
	GModule *module;

	plugin_get_info func_get_info;
	plugin_free_info func_free_info;
	plugin_activate func_activate;
	plugin_deactivate func_deactivate;
	plugin_action func_action;
};

#endif /* __MODULE_LOADER_H__ */
